//
//  ToDaySubViewController.m
//  TourPlay
//
//  Created by dllo on 15/11/19.
//  Copyright © 2015年 王军岐. All rights reserved.
//

#import "ToDaySubViewController.h"
#import "TodayHomeCell.h"
#import "TodayHomeModel.h"
#import "ActivitieDetailsViewController.h"

@interface ToDaySubViewController () <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, retain) UITableView *myTableV;

@end

@implementation ToDaySubViewController
- (void)dealloc
{
    [_time release];
    [_myTableV release];
    [_subArr release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.view.backgroundColor = [UIColor colorWithRed:0.94 green:0.94 blue:0.94 alpha:1];
    self.navigationItem.title = self.time;
    
    // 划线
    UIView *viewBack = [[UIView alloc] initWithFrame:CGRectMake(17, 0, 1, self.view.frame.size.height)];
    [self.view addSubview:viewBack];
    [viewBack release];
    
    [self addColorChangedBlock:^{
        
        viewBack.nightBackgroundColor = [ColorSingleton shareSingleton].cellColor;
        viewBack.normalBackgroundColor = [UIColor colorWithRed:0.88 green:0.87 blue:0.88 alpha:1];
    }];
    
    
    
    self.myTableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 6, SCREEN_WIDTH, SCREEN_HEIGHT - 64 - 6) style:UITableViewStylePlain];
    self.myTableV.backgroundColor = [UIColor clearColor];
    self.myTableV.delegate = self;
    self.myTableV.dataSource = self;
    [self.myTableV registerClass:[TodayHomeCell class] forCellReuseIdentifier:@"cell"];
    [self.view addSubview:self.myTableV];
    [_myTableV release];
    
    // 取消分割线
    self.myTableV.separatorStyle = UITableViewCellSeparatorStyleNone;

}
- (void)leftAction
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 表格
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return (SCREEN_HEIGHT - 50 - 49 - 64) / 3.f;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.subArr.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellStr = @"cell";
    TodayHomeCell *cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
    cell.backgroundColor = [UIColor clearColor];
    TodayHomeModel *mod = [self.subArr objectAtIndex:indexPath.row];
    cell.toDayMod = mod;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 选中时有置灰效果, 离开时消失选中效果
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    TodayHomeModel *mod = [self.subArr objectAtIndex:indexPath.row];
    
    ActivitieDetailsViewController *activitieVC = [[ActivitieDetailsViewController alloc] init];
    
    activitieVC.activityId = mod.toDayId;
    activitieVC.activityTitle = mod.title;
    // 隐藏
    activitieVC.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:activitieVC animated:YES];
    [activitieVC release];

    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
